<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>领域模型设计模式：贫血模型与充血模型</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
        }
        .serif-font {
            font-family: 'Noto Serif SC', serif;
        }
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            margin-top: 0.5rem;
            font-weight: 700;
            color: #667eea;
        }
        .section-divider {
            position: relative;
            text-align: center;
            margin: 4rem 0;
        }
        .section-divider::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 1px;
            background: linear-gradient(to right, transparent, #e5e7eb, transparent);
        }
        .section-divider span {
            background: white;
            padding: 0 2rem;
            position: relative;
            color: #9ca3af;
            font-size: 0.875rem;
        }
        .feature-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
            font-size: 24px;
            margin-bottom: 1rem;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="relative overflow-hidden bg-gradient-to-br from-purple-50 via-white to-blue-50 py-20">
        <div class="absolute inset-0 bg-white opacity-50"></div>
        <div class="relative max-w-6xl mx-auto px-6">
            <div class="text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 serif-font">
                    <span class="gradient-text">领域模型设计模式</span>
                </h1>
                <p class="text-2xl text-gray-700 mb-8">贫血模型与充血模型的深度解析</p>
                <div class="max-w-3xl mx-auto">
                    <p class="text-lg text-gray-600 leading-relaxed drop-cap">
                        领域模型是一个面向对象的设计模式，用于表示和处理业务领域中的数据和逻辑。在软件架构的演进中，贫血模型和充血模型代表了两种截然不同的设计哲学，它们各自在特定场景下展现出独特的优势。
                    </p>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-6xl mx-auto px-6 py-16">
        <!-- 领域模型概述 -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-lg p-8 card-hover">
                <div class="flex items-center mb-6">
                    <div class="feature-icon bg-gradient-to-br from-purple-500 to-purple-600 text-white">
                        <i class="fas fa-cube"></i>
                    </div>
                    <h2 class="text-3xl font-bold ml-4 serif-font">什么是领域模型？</h2>
                </div>
                <p class="text-gray-700 leading-relaxed mb-6">
                    领域模型是面向对象设计中的核心概念，它通过类、对象及其关系来抽象和表达业务领域。这种模型不仅仅是数据的容器，更是业务逻辑和规则的载体，使开发者能够用代码精确地实现复杂的业务需求。
                </p>
                
                <!-- 特点卡片 -->
                <div class="grid md:grid-cols-3 gap-6 mt-8">
                    <div class="bg-gradient-to-br from-purple-50 to-white p-6 rounded-xl border border-purple-100">
                        <i class="fas fa-briefcase text-purple-600 text-2xl mb-3"></i>
                        <h3 class="font-semibold text-lg mb-2">业务导向</h3>
                        <p class="text-gray-600 text-sm">专注于业务需求和规则，而非技术实现细节</p>
                    </div>
                    <div class="bg-gradient-to-br from-blue-50 to-white p-6 rounded-xl border border-blue-100">
                        <i class="fas fa-layer-group text-blue-600 text-2xl mb-3"></i>
                        <h3 class="font-semibold text-lg mb-2">抽象封装</h3>
                        <p class="text-gray-600 text-sm">将业务逻辑和数据紧密结合，确保完整性</p>
                    </div>
                    <div class="bg-gradient-to-br from-indigo-50 to-white p-6 rounded-xl border border-indigo-100">
                        <i class="fas fa-brain text-indigo-600 text-2xl mb-3"></i>
                        <h3 class="font-semibold text-lg mb-2">领域知识</h3>
                        <p class="text-gray-600 text-sm">包含并体现领域专家的专业知识</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- 模型对比可视化 -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-lg p-8">
                <h2 class="text-3xl font-bold mb-8 text-center serif-font">模型架构对比</h2>
                <div class="mermaid">
                    graph TB
                        subgraph "贫血模型"
                            A1[领域对象<br/>仅包含数据] --> B1[Service层<br/>包含业务逻辑]
                            B1 --> C1[数据访问层]
                            style A1 fill:#fef3c7,stroke:#f59e0b
                            style B1 fill:#ddd6fe,stroke:#8b5cf6
                        end
                        
                        subgraph "充血模型"
                            A2[领域对象<br/>数据+业务逻辑] --> C2[数据访问层]
                            style A2 fill:#c7d2fe,stroke:#6366f1
                        end
                </div>
            </div>
        </section>

        <!-- 贫血模型详解 -->
        <section class="mb-16">
            <div class="section-divider">
                <span><i class="fas fa-circle"></i></span>
            </div>
            
            <div class="bg-gradient-to-r from-yellow-50 to-orange-50 rounded-2xl p-8 mb-8">
                <div class="flex items-center mb-6">
                    <div class="feature-icon bg-gradient-to-br from-yellow-400 to-orange-500 text-white">
                        <i class="fas fa-database"></i>
                    </div>
                    <h2 class="text-3xl font-bold ml-4 serif-font">贫血模型</h2>
                </div>
                
                <p class="text-gray-700 leading-relaxed mb-6">
                    贫血模型采用了一种分离关注点的设计理念，将数据和行为分开管理。在这种模式下，领域对象就像是纯粹的数据容器，仅负责数据的存储和基本访问，而所有的业务逻辑都被提取到独立的服务层中。
                </p>

                <div class="grid md:grid-cols-2 gap-6 mt-8">
                    <!-- 优点 -->
                    <div class="bg-white rounded-xl p-6 shadow-md">
                        <h3 class="text-xl font-semibold mb-4 text-green-600">
                            <i class="fas fa-check-circle mr-2"></i>优点
                        </h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-chevron-right text-green-500 mt-1 mr-3"></i>
                                <div>
                                    <strong>易于实现和维护</strong>
                                    <p class="text-gray-600 text-sm mt-1">特别适合业务逻辑复杂且变动频繁的场景</p>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-chevron-right text-green-500 mt-1 mr-3"></i>
                                <div>
                                    <strong>高度解耦</strong>
                                    <p class="text-gray-600 text-sm mt-1">业务逻辑与领域模型分离，提高了系统的灵活性</p>
                                </div>
                            </li>
                        </ul>
                    </div>

                    <!-- 缺点 -->
                    <div class="bg-white rounded-xl p-6 shadow-md">
                        <h3 class="text-xl font-semibold mb-4 text-red-600">
                            <i class="fas fa-times-circle mr-2"></i>缺点
                        </h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-chevron-right text-red-500 mt-1 mr-3"></i>
                                <div>
                                    <strong>领域对象缺乏表现力</strong>
                                    <p class="text-gray-600 text-sm mt-1">业务逻辑分散，可能导致代码难以理解</p>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-chevron-right text-red-500 mt-1 mr-3"></i>
                                <div>
                                    <strong>数据一致性挑战</strong>
                                    <p class="text-gray-600 text-sm mt-1">业务规则与数据管理分离可能引发一致性问题</p>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- 充血模型详解 -->
        <section class="mb-16">
            <div class="bg-gradient-to-r from-blue-50 to-purple-50 rounded-2xl p-8">
                <div class="flex items-center mb-6">
                    <div class="feature-icon bg-gradient-to-br from-blue-500 to-purple-600 text-white">
                        <i class="fas fa-cogs"></i>
                    </div>
                    <h2 class="text-3xl font-bold ml-4 serif-font">充血模型</h2>
                </div>
                
                <p class="text-gray-700 leading-relaxed mb-6">
                    充血模型代表了面向对象设计的精髓，它将数据和行为紧密结合在一起。领域对象不再是简单的数据载体，而是成为了真正的业务实体，既包含数据属性，也承载着处理这些数据的业务逻辑。
                </p>

                <div class="grid md:grid-cols-2 gap-6 mt-8">
                    <!-- 优点 -->
                    <div class="bg-white rounded-xl p-6 shadow-md">
                        <h3 class="text-xl font-semibold mb-4 text-green-600">
                            <i class="fas fa-check-circle mr-2"></i>优点
                        </h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-chevron-right text-green-500 mt-1 mr-3"></i>
                                <div>
                                    <strong>高内聚性</strong>
                                    <p class="text-gray-600 text-sm mt-1">业务逻辑封装在领域对象中，提高了代码的表达力</p>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-chevron-right text-green-500 mt-1 mr-3"></i>
                                <div>
                                    <strong>业务规则一致性</strong>
                                    <p class="text-gray-600 text-sm mt-1">数据和逻辑的紧密结合确保了业务规则的完整性</p>
                                </div>
                            </li>
                        </ul>
                    </div>

                    <!-- 缺点 -->
                    <div class="bg-white rounded-xl p-6 shadow-md">
                        <h3 class="text-xl font-semibold mb-4 text-red-600">